#ifndef IMAGECOMPARATOR_H
#define IMAGECOMPARATOR_H

#include <opencv/cv.h>

using namespace cv;

namespace controllers {

    enum ComparisonTypes { NORMAL, HUE, SPARSE };

    /**
     * @brief The ImageComparator class is used to compare images using their histograms
     *
     * Adapted from:
     *      OpenCV2 Computer Vision Application programming Cookbook
     *      of Robert Laganière
     */
    class ImageComparator
    {
    public:
        ImageComparator();
        virtual ~ImageComparator();
        void    setColorReduction(int factor);
        int     getColorReduction();
        void    setReferenceImage(const cv::Mat& image);
        double  compareWithReference(const cv::Mat& image, ComparisonTypes type);
        double  compareHistograms(const SparseMat& hist1, const SparseMat& hist2, ComparisonTypes type);
        double  compareWithRefWithRef(ComparisonTypes type);

    private:
        int             _div;
        Mat             _reference;
        Mat             _input;
        SparseMat       _refHist;
        SparseMat       _refHueHist;
        SparseMat       _refSparseHist;
        SparseMat       _inputH;
    };
}

#endif // IMAGECOMPARATOR_H
